﻿@model ECatalog.Models.Model[]

@{
    ViewBag.Title = "Модели";
    Layout = "../Shared/_Layout.cshtml";
}
<div class="container">
    <div class="row">
        @using (@Html.BeginForm("AddModel", "Model", FormMethod.Post))
        {            
            <p>
                <button type="submit" class="btn btn-primary">Добавить модель</button>
            </p> 
        }
    </div>
    <div class="row">
        <table class="table table-bordered table-hover">
            <thead>
                <tr>
                    <th>UID</th>
                    <th>Фотография</th>
                    <th>Номер каталога</th>
                    <th>Описание</th>
                    <th>Действия</th>
                </tr>
            </thead>
            <tbody>
                @if (Model != null && Model.Length > 0)
                {
                    foreach (var item in Model)
                    {
                    <tr>
                        <td>@item.ModelId</td>
                        <td>
                            @{ 
                            var imageUrl = string.Format("/Files/Organization-{0}/Model-{1}/{2}/800x600/{3}{4}", @item.OrganizationId, @item.ModelId, @item.ImageUrl, @item.ImageUrl,@item.TypeImage);
                            }
                            <img src="@imageUrl" width="200" />
                        </td>
                        <td>@item.CatNumber</td>
                        <td>@item.Description</td>
                        <td>@using (@Html.BeginForm("EditModel", "Model", new { item.ModelId }, FormMethod.Post))
                            {
                            <button type="submit" class="btn btn-link">Редактировать</button>
                            }
                            @using (@Html.BeginForm("DeleteModel", "Model", new { item.ModelId }, FormMethod.Post))
                            {
                                <button type="submit" class="btn btn-link">Удалить</button>
                            }
                        </td>
                    </tr>
                    }
                }
            </tbody>
        </table>
    </div>
</div>

